home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 167_01 / more.c < prev    next >
Text File  |  1985-08-19  |  2KB  |  99 lines

  1. /* 
  2. HEADER:     CUG
  3. TITLE:        MORE.C - An Emulation of MS-DOS 'more' Utility
  4.              for CP/M
  5. VERSION:    1.00
  6. DATE:        11/08/85
  7. DESCRIPTION:    "An emulation of MS-DOS 'more' utility for use
  8.         with the CP/M operating system "
  9. KEYWORDS:    more, filter, utility, CP/M
  10. SYSTEM:        Any CP/M system
  11. FILENAME:    MORE.C
  12. WARNINGS:    NONE
  13. CRC:        xxxx
  14. SEE-ALSO:    NONE
  15. AUTHORS:    Ian Ashdown - byHeart Software
  16. COMPILERS:    ANY
  17. REFERENCES:    AUTHORS:
  18.         TITLE:
  19. ENDREF
  20. */
  21.  
  22. /*-------------------------------------------------------------*/
  23.  
  24. /* MORE.C - An Emulation of MS-DOS "more" Utility for CP/M
  25.  *
  26.  * Version 1.00        September 15th, 1985
  27.  *
  28.  * Copyright 1985:    Ian Ashdown
  29.  *            byHeart Software
  30.  *            2 - 2016 West First Avenue
  31.  *            Vancouver, B.C. V6J 1G8
  32.  *
  33.  * Synopsis:    MORE < [file]
  34.  *
  35.  * Description:    MORE is used to view a long text file one screen
  36.  *        at a time. If there is more information to be
  37.  *        displayed, -MORE- appears at the bottom of the
  38.  *        screen. Press any key to display another screen
  39.  *        of information. This process continues until all
  40.  *        the input file has been read via the standard
  41.  *        input. CNTL-C can be used to terminate the
  42.  *        program.
  43.  *
  44.  * Diagnostics: None.
  45.  *
  46.  * Bugs:    Lines longer than 256 characters are truncated.
  47.  */
  48.  
  49. /*** Include Files ***/
  50.  
  51. #include <stdio.h>
  52.  
  53. /*** Definitions ***/
  54.  
  55. #define BREAK    0x03    /* Define CNTL-C as break key */
  56. #define BUFLEN     257    /* Length of line buffer */
  57. #define SCR_HT      24    /* Terminal screen height in lines */
  58.  
  59. /*** Main Body of Program ***/
  60.  
  61. main()
  62. {
  63.   char c,
  64.        buffer[BUFLEN],
  65.        *fgets();
  66.   int i;
  67.  
  68.   while(1)
  69.   {
  70.     for(i = 1; i < SCR_HT; i++)        /* Display a screen */
  71.     {
  72.       if(fgets(buffer,BUFLEN,stdin) == NULL)  /* End of file ? */
  73.     exit(0);
  74.       else                /* Display a line */
  75.     printf(buffer);
  76.     }
  77.     printf("-MORE- ");
  78.     do            /* Wait for operator response */
  79.       c = bdos(6,0xff);    /* (No character echo to screen) */
  80.     while(c == NULL);
  81.     if(c == BREAK)    /* Terminate program? */
  82.       break;
  83.     putchar('\n');
  84.   }
  85. }
  86.  
  87. /*** Explanation of Aztec CII Functions ***/
  88.  
  89. /* bdos(bc,de)
  90.  * int bc,de;
  91.  *
  92.  * Calls CP/M's BDOS with 8080 CPU register pair BC set to "bc"
  93.  * and register pair DE set to "de". The value returned by the
  94.  * 8080 CPU accumulator is the return value.
  95.  */
  96.  
  97. /*** End of MORE.C ***/
  98. #define BREAK    0x03    /* Define CNTL-C as break key */
  99. #define BUFLEN     25